﻿<?php
/**
 *
 * @author Duminda Dharmakeerthi
 *
 */
class student{
	private $studentId;
	private $studentIndex;
	private $studentNameWithInitials;
	private $studentFullName;
	private $studentGender;
	private $studentDateOfBirth;
	private $studentHealthInfo;
	private $studentSpecialSkills;
	private $fatherName;
	private $fatherOccupation;
	private $motherName;
	private $motherOccupation;
	private $guardianName;
	private $guardianOccupation;

	function __construct(){
	}

	public static function fillStudent($studentIndex, $studentNameWithInitials, $studentFullName, $studentGender, $studentDateOfBirth, $studentHealthInfo, $studentSpecialSkills, $guardianName, $guardianOccupation, $fatherName, $fatherOccupation, $motherName, $motherOccupation){
		$S = new self();
		$S->setStudent($studentIndex, $studentNameWithInitials, $studentFullName, $studentGender, $studentDateOfBirth, $studentHealthInfo, $studentSpecialSkills, $guardianName, $guardianOccupation, $fatherName, $fatherOccupation, $motherName, $motherOccupation);
		return $S;
	}

	protected function setStudent($studentIndex, $studentNameWithInitials, $studentFullName, $studentGender, $studentDateOfBirth, $studentHealthInfo, $studentSpecialSkills, $guardianName, $guardianOccupation, $fatherName, $fatherOccupation, $motherName, $motherOccupation){
		$this->studentIndex = $studentIndex;
		$this->studentNameWithInitials = $studentNameWithInitials;
		$this->studentFullName = $studentFullName;
		$this->studentGender = $studentGender;
		$this->studentDateOfBirth = $studentDateOfBirth;
		$this->studentHealthInfo = $studentHealthInfo;
		$this->studentSpecialSkills = $studentSpecialSkills;
		$this->guardianName = $guardianName;
		$this->guardianOccupation = $guardianOccupation;
		$this->fatherName = $fatherName;
		$this->fatherOccupation = $fatherOccupation;
		$this->motherName = $motherName;
		$this->motherOccupation = $motherOccupation;
	}

	/**
	 * Adding a student.
	 *
	 * @return Id of the added student or '0' if error occured.
	 */
	public function addStudent(){
		$addStudentQuery = "INSERT INTO students (
								studentIndex,
								studentNameWithInitials,
								studentFullName,
								studentGender,
								studentDateOfBirth,
								studentHealthInfo,
								studentSpecialSkills,
								guardianName,
								guardianOccupation,
								fatherName,
								fatherOccupation,
								motherName,
								motherOccupation
							)VALUES (													
								'$this->studentIndex',
								'$this->studentNameWithInitials',
								'$this->studentFullName',
								'$this->studentGender',
								'$this->studentDateOfBirth',
								'$this->studentHealthInfo',
								'$this->studentSpecialSkills',
								'$this->guardianName',
								'$this->guardianOccupation',
								'$this->fatherName',
								'$this->fatherOccupation',
								'$this->motherName',
								'$this->motherOccupation'
							)";
		if(mysql_query($addStudentQuery)){
			return mysql_insert_id();
		}else{
			return 0;
		}
	}
	
	public function updateStudent($studentId){
		
	}
	
	public function inactiveStudent($studentId){
	
	}
	
	public function activeStudent($studentId){
	
	}
}
?>